package top.jamsee.dao;

import org.apache.ibatis.annotations.*;
import top.jamsee.entity.Buy_data;
import top.jamsee.entity.Lent_data;

import java.util.List;

public interface LentDao {
    //查看租房表的数据

    public List<Lent_data> selectLentData();
    //根据id查询是否有此条记录,更新表时使用
    @Select("select count(0) from lent where id=#{id}")
    public int selectLentById(@Param("id") int id);
    //查看lent表有多少条数据用于分页
    @Select("select count(0) from lent")
    public int selectLentNum();
    //删除租房表的数据(按id)
    @Delete("delete from lent where id=#{id}")
    public int deleteLentDataById(@Param("id") int id);
    //添加租房表数据
    @Insert("insert into lent (title,insert_time,operate_person,imgAddress,typeHouse_area,advantages,if_need_show)" +
            " values(#{title},#{insert_time},#{operate_person},#{imgAddress},#{typeHouse_area},#{advantages},#{if_need_show})")
    public int addLentData(Lent_data lent_data);
    //模糊查询lent表
    @Select("SELECT * FROM `lent` where title LIKE CONCAT('%',#{data},'%')")
    public List<Lent_data> selectLentByData(@Param("data") String data );
    //模糊查询lent表的所有数量方便后续分页
    @Select("SELECT count(0) FROM `lent` where title LIKE CONCAT('%',#{data},'%')")
    public int selectLentByDataNum(@Param("data") String data );
    //更新lent表根据id
    @Update("Update lent set operate_person=#{operate_person},title=#{title},insert_time=#{insert_time}," +
            "imgAddress=#{imgAddress},typeHouse_area=#{typeHouse_area}" +
            ",advantages=#{advantages},if_need_show=#{if_need_show}" +
            "  where id=#{id};")
    public int upDateLentById(Lent_data lent_data);

}
